/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.model.store.faststore;
import java.util.ArrayList;
import simhya.matheval.SymbolArray;
import simhya.model.store.StoreException;
import simhya.model.store.Predicate;
import simhya.matheval.Expression;

/**
 *
 * @author Luca
 */
public class GenericPredicate implements Predicate {
   private Expression exp;

    public GenericPredicate(Expression exp) {
        if (!exp.isLogicalExpression())
            throw new StoreException("The expression defining the predicate is not a logical expression: " + exp.toString());
        this.exp = exp;
    }

    public boolean evaluate() {
        if (exp.computeValue() == 1.0) return true;
        else return false;
    }

    public boolean evaluate(SymbolArray vars) {
        if (exp.computeValue(vars) == 1.0) return true;
        else return false;
    }

    public boolean evaluateCache() {
        if (exp.computeValueCache() == 1.0) return true;
        else return false;
    }

    public boolean evaluateCache(SymbolArray vars) {
        if (exp.computeValueCache(vars) == 1.0) return true;
        else return false;
    }

    public ArrayList<Integer> getVariableList() {
        return exp.getListOfVariables();
    }

    public void initialize() {  }

    public boolean isContradiction() {
        return false;
    }

    public boolean isTautology() {
        return false;
    }



    public String toModelLanguage() {
        return this.exp.toString();
    }




}
